package io.kiki.stack.http.feign.example.wikipedia;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.util.Arrays;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Run main for {@link WikipediaExampleIT}
 */
class WikipediaExampleIT {

    @Test
    void runMain() throws Exception {
        final String jar = Arrays.stream(new File("target").listFiles()).filter(file -> file.getName().startsWith("feign-example-wikipedia-with-springboot") && file.getName().endsWith(".jar")).findFirst().map(File::getAbsolutePath).get();

        final String line = "java -jar " + jar;
        final CommandLine cmdLine = CommandLine.parse(line);
        final int exitValue = new DefaultExecutor().execute(cmdLine);

        assertThat(exitValue).isEqualTo(0);
    }
}
